#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
long long sum;
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		sum = 0;
		while (n--)
		{
			int  a, b;
			cin >> a >> b;
			if (a - b > 0)
				sum++;
		}
		cout << sum << endl;
	}
	return 0;
}